package com.shoulei.designpattern.flyweightPattern;

/**
 * @ClassName:FlyWeightPatternDemo
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/4/14 15:26
 * @Verson:
 */
public class FlyWeightPatternDemo {
    private static final String colors [] = {"red","green","blue"};

    public static void main(String[] args) {
        for (int i=0;i<20;i++){
           Circle circle = (Circle) ShapeFactory.getCircle(getRandowColor());
           circle.setRadius(getRandowRadius());
           circle.setX(getRandomX());
           circle.setY(getRandowY());
           circle.draw();
        }
    }

    private static String getRandowColor(){
        return colors[(int)(Math.random()*colors.length)];
    }
    private static int getRandomX(){
        return (int) (Math.random()*100);
    }
    private static int getRandowY(){
        return (int) (Math.random()*100);
    }
    private static int getRandowRadius(){
        return (int) (Math.random()*100);
    }
}
